﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace JingQiao.Ads.Infrastructure.Data.NH.Repository
{
    using Domain.Model;
    using Domain.Model.DomainObject;
    using Domain.Model.Repository;

    public class ConfigInfoRepository : BaseRepository<IConfigInfo>, IConfigInfoRepository
    {
        public ConfigInfoRepository(IContext context)
            : base(context)
        {
        }

        public bool ContainsDestination(int configInfoId)
        {
            return false;
        }

        public IConfigInfo FindById(int id)
        {
            Check.Argument.IsNotNegativeOrZero(id, "id");
            return null;
        }

        public IQueryable<IConfigInfo> FindByIds(string ids)
        {
            return null;
        }

        public void Remove(string ids)
        {
            var configInfos = FindByIds(ids);
            this.Remove(configInfos);
        }

        public void Remove(IEnumerable<IConfigInfo> configInfos)
        {
            this._context.DeleteAll(configInfos);
        }

        public IQueryable<IConfigInfo> FindAll()
        {
            return null;
        }

        public PagedResult<IConfigInfo> FindAll(int pageSize, int pageIndex)
        {
            return Find(pageSize, pageIndex, null);
        }

        public PagedResult<IConfigInfo> FindByName(int pageSize, int pageIndex, string nameKeyword)
        {
            if (!string.IsNullOrEmpty(nameKeyword))
                return Find(pageSize, pageIndex, x => x.Name.Contains(nameKeyword));
            return Find(pageSize, pageIndex, null);
        }

        #region 私有方法

        private PagedResult<IConfigInfo> Find(int pageSize, int pageIndex, Expression<Func<IConfigInfo, bool>> predicate)
        {
            return null;
        }

        private int Count(Expression<Func<IConfigInfo, bool>> predicate)
        {
            return 0;
        }

        #endregion
    }
}
